package duoxianc;

public class eat extends Thread{
    @Override
    public void run() {
        while (true){
            synchronized (desk.lock){
                if (desk.number == 0){
                    break;
                }else {
                    if (desk.flag == 0){
                        try {
                            desk.lock.wait();
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                    }else {
                        desk.number--;
                        System.out.println("正在吃面条，还能吃"+desk.number+"碗");
                        desk.lock.notifyAll();
                        desk.flag = 0;
                    }
                }
            }
        }
    }
}
